import axios from 'axios';

function getRandomNumber(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

function getRandomOperator() {
  const operators = ['+', '-', '*', '/'];
  return operators[Math.floor(Math.random() * operators.length)];
}

function generateMixedArithmeticOperation() {
  const operand1 = getRandomNumber(1, 100);
  const operand2 = getRandomNumber(1, 100);
  const operator1 = getRandomOperator();
  const operator2 = getRandomOperator();
  const operator3 = getRandomOperator();
  return `${operand1} ${operator1} ${operand2} ${operator2} ${operator3} ${getRandomNumber(1, 100)}`;
}

const mixedArithmeticOperation = generateMixedArithmeticOperation();
console.log(mixedArithmeticOperation);

function generateQuestions(numQuestions) {
  const questions = [];
  for (let i = 0; i < numQuestions; i++) {
    const question = generateMixedArithmeticOperation();
    questions.push(question);
  }
  return questions;
}

export function convertHanzi(hangzi) {
  return axios.get(
    `https://www.mxnzp.com/api/convert/dictionary?content=${hangzi}&app_id=gwytpwfqthfkor6i&app_secret=R0FHQm0veXdxaXVORDdVYzErL1hxUT09`,
  );
}

export function searchHZ(z = '') {
  return axios.get(`https://w5yhq27yyp.hk.aircode.run/zi`, { params: { z } });
}